package com.fjnldx.mes.controller.productionFigures;

import com.fjnldx.mes.domain.domainReq.DateSectionReq;
import com.fjnldx.mes.domain.domainReq.HistoricalEmployment;
import com.fjnldx.mes.domain.domainReq.PageRequest;
import com.fjnldx.mes.domain.domainRes.Result;
import com.fjnldx.mes.domain.pojo.MesNewscjh;
import com.fjnldx.mes.service.productionFigures.ProductionFiguresService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/productionFigures")
@Api(value = "生产统计管理", tags = "生产统计管理模块")
public class ProductionFiguresController {

    @Resource
    private ProductionFiguresService productionFiguresService;

    @PostMapping("/getHistoryTrackData")
    @ApiOperation(value = "历史轨迹实时数据", notes = "Api")
    public Result getHistoryTrackData(@RequestBody DateSectionReq dateSectionReq) {
        return productionFiguresService.getHistoryTrackData(dateSectionReq);
    }

    @GetMapping("/getHistoryTrackDataByPage")
    @ApiOperation(value = "历史轨迹实时表格", notes = "Api")
    public Result getHistoryTrackDataByPage(PageRequest pageRequest, DateSectionReq dateSectionReq) {
        return productionFiguresService.getHistoryTrackDataByPage(dateSectionReq, pageRequest);
    }

    @PostMapping("/queryHistoricalEmployment")
    @ApiOperation(value = "用工历史记录", notes = "用工历史记录")
    public Result queryHistoricalEmployment(@RequestBody HistoricalEmployment historicalEmployment) {
        return productionFiguresService.queryHistoricalEmployment(historicalEmployment);
    }

    @PostMapping("/queryHistoricalWorkersData")
    @ApiOperation(value = "历史数据查询", notes = "历史数据查询")
    public Result queryHistoricalEmployment(@RequestBody MesNewscjh mesNewscjh) {
        return productionFiguresService.queryHistoricalWorkersData(mesNewscjh);
    }

    @GetMapping("/exportHistoricalWorkersData")
    @ApiOperation(value = "导出所有历史数据", notes = "导出所有历史数据")
    public void exportHistoricalWorkersData(HttpServletRequest request, HttpServletResponse response) throws Exception {
        productionFiguresService.exportHistoricalWorkersData(request, response);
    }

    @PostMapping("/test")
    @ApiOperation(value = "test", notes = "test")
    public void test() {
        System.out.println("告警");
    }
}
